package com.astrob.activitys;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.astrob.nhcmap.R;

import zuo.biao.library.util.ImageLoaderUtil;
import zuo.biao.library.util.StringUtil;

public class ShowPicActivity extends Activity {

    public static final String INTENT_SHOWPIC_URL = "INTENT_SHOWPIC_URL";

    public static Intent createIntent(Context context, String url) {
        return new Intent(context, ShowPicActivity.class)
                .putExtra(INTENT_SHOWPIC_URL, url);
    }

    String _picurl;
    private ImageView ivImage;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.showpic_activity);

        _picurl = getIntent().getStringExtra(INTENT_SHOWPIC_URL);

        ivImage = (ImageView) findViewById(R.id.iv_image);
        showPic();

    }

    private boolean showPic() {
        if (_picurl == null || _picurl.length() < 1) {
            return false;
        }

        if (StringUtil.isFilePath(_picurl) == false) {
            return false;
        }

        ImageLoaderUtil.loadImage(ivImage, _picurl);

        return true;
    }

    public void onBack(View v) {
        finish();
    }

}